from django.http import JsonResponse
from django.views.decorators.csrf import csrf_exempt
from itsdangerous import TimedJSONWebSignatureSerializer as Serializer
import datetime
from tenfold_pro import settings
def generate_tokens(user_id):
    s = Serializer(secret_key=settings.SECRET_KEY, expires_in=60*60*2)
    token = s.dumps({'user_id': user_id, 'refresh': False}).decode('utf-8')
    return token
def check_token(token):
    s = Serializer(
        secret_key=settings.SECRET_KEY,
    )
    try:
        data = s.loads(token)
    except Exception as e:
        return None
    else:
        return data